package com.cty.controller;

import com.cty.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@ResponseBody
@RequestMapping("user")
public class UserController {

    @GetMapping
    public List<User> page(@RequestParam(required = false,defaultValue = "1") int page,
                           @RequestParam(required = false,defaultValue = "10") int size) {
        System.out.println("page = " + page + ", size = " + size);
        return null;
    }

    @PostMapping
    public User add(@RequestBody User user) {
        System.out.println("user = " + user);
        return user;
    }

    @GetMapping("{id}")
    public User query(@PathVariable("id") Integer id) {
        System.out.println("id = " + id);
        return null;
    }


    @PutMapping
    public Integer update(@RequestBody User user) {
        System.out.println("user = " + user);
        return null;
    }

    @DeleteMapping("{id}")
    public Integer delete(@PathVariable(value = "id") Integer id) {
        System.out.println("id = " + id);
        return null;
    }

    @GetMapping("search")
    public List<User> search(@RequestParam(required = false,defaultValue = "1") int page,@RequestParam(required = false,defaultValue = "10") int size,String keywork) {
        System.out.println("page = " + page + ", size = " + size + ", keyWork = " + keywork);
        return null;
    }
}
